package com.pkk.penguin.frame.know.java.driven.condition.config;

import com.pkk.penguin.frame.know.java.driven.condition.bean.SimpleBean;
import com.pkk.penguin.frame.know.java.driven.condition.condition.simple.LinuxCondition;
import com.pkk.penguin.frame.know.java.driven.condition.condition.simple.WindowCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @description: bean创建
 * @author: peikunkun
 * @create: 2020-07-30 17:58
 **/
@Configuration
public class BeanConfig {

  /**
   * @Description: 创建一个bean为linux条件为LinuxCondition.class限制的bean
   * @Param:
   * @return: com.pkk.penguin.frame.know.java.driven.condition.bean.SimpleBean
   * @Author: peikunkun
   * @Date: 2020/7/30 0030 下午 6:01
   */
  @Conditional(LinuxCondition.class)
  @Bean("linux")
  public SimpleBean linuxSimpleBean() {
    return new SimpleBean("linux");
  }


  /**
   * @Description: 创建一个bean为window条件为WindowCondition.class限制的bean
   * @return: com.pkk.penguin.frame.know.java.driven.condition.bean.SimpleBean
   * @Author: peikunkun
   * @Date: 2020/7/30 0030 下午 6:02
   */
  @Conditional(WindowCondition.class)
  @Bean("window")
  public SimpleBean windowSimpleBean() {
    return new SimpleBean("window");
  }


}
